#include "StdAfx.h"
#include "worktimer.h"

CWorkTimer::CWorkTimer(void)
: m_pTimer(NULL)
, m_bSkip(TRUE)
{
}

CWorkTimer::~CWorkTimer(void)
{
	if(m_pTimer != NULL)
	{
		delete m_pTimer;
		m_pTimer = NULL;
	}
}
void CWorkTimer::WorkTimerProc(UINT uTimerID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
	CWorkTimer* This = (CWorkTimer*)dwUser;
	if(!This->m_bSkip)
        This->TimerFunction(uTimerID);
}
void CWorkTimer::TimerFunction(UINT uTimerID)
{
}
void CWorkTimer::SetWorkTimer(UINT nInterval, UINT nResolution)
{
	if(m_pTimer == NULL)
	{
		m_pTimer = new CSetPreciseTimer();
	}
	m_pTimer->SetMMTimer(nInterval, nResolution, WorkTimerProc, (DWORD)this);
}

void CWorkTimer::KillWorkTimer(void)
{
	m_pTimer->KillMMTimer();
}

void CWorkTimer::AttachWnd(HWND hWnd)
{
	m_hWnd = hWnd;
}

void CWorkTimer::SkipWorkOrNO(BOOL bSkip)
{
	m_bSkip = bSkip;
}

BOOL CWorkTimer::GetSkipStatus(void)
{
	return m_bSkip;
}

void CWorkTimer::SetWorkTimer(UINT nInterval)
{
	if(m_pTimer == NULL)
	{
		m_pTimer = new CSetPreciseTimer();
		//m_pTimer->StartTimer();
	}
	m_pTimer->SetMMTimeOnce(nInterval, 1, WorkTimerProc, (DWORD)this);
}
